package com.fatcat.easybuy.mapper;


import com.fatcat.easybuy.pojo.EasyBuyOrderDetail;
import com.fatcat.easybuy.pojo.EasyBuyProduct;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
* @author Fatcat
* @description 针对表【easybuy_product】的数据库操作Mapper
* @createDate 2025-09-10 11:01:40
* @Entity generator.domain.EasybuyProduct
*/
@Mapper
@Repository
public interface EasyBuyProductMapper {
    //查询所有商品
    List<EasyBuyProduct> selectAllProduct(Map<String, Object> params);
    //根据id列表获取商品列表  批量查询商品
    List<EasyBuyProduct> getProductsByIds(List<Long> productIds);
    //添加商品
    int addProduct(EasyBuyProduct product);
    //根据id更新商品
    int updateProduct(EasyBuyProduct product);
    //根据id删除商品
    int deleteProduct(Long id);
    //根据id查询商品
    EasyBuyProduct selectProductById(Long id);
    //批量更新商品临时库存
    int updateProductTempStockByList(List<EasyBuyOrderDetail> orderDetailList);
    //根据订单详情更新商品正式库存
    int updateProductStockByList(List<EasyBuyOrderDetail> orderDetailList);
    //根据订单详情回滚临时库存
    int rollbackProductTempStockByList(List<EasyBuyOrderDetail> orderDetailList);
    //根据订单详情回滚正式库存
    int rollbackProductStockByList(List<EasyBuyOrderDetail> orderDetailList);
    //检查分类id下是否存在产品
    int checkExitProductOfLevel1(Long id);
    int checkExitProductOfLevel2(Long id);
    int checkExitProductOfLevel3(Long id);

    //修改分类时，一并修改产品的level1、level2、level3,返回数大于等于0
    int updateProductLevel(
            @Param("categoryLevel1Id") Long categoryLevel1Id,
            @Param("categoryLevel2Id") Long categoryLevel2Id,
            @Param("categoryLevel3Id") Long categoryLevel3Id,
            @Param("categoryId") Long categoryId
    );

}
